/**
 * <copyright>
 * </copyright>
 *
 */
package dk.nineconsult.jmoller.mapr.mapr.impl;

import dk.nineconsult.jmoller.mapr.mapr.Expression;
import dk.nineconsult.jmoller.mapr.mapr.FeatureMap;
import dk.nineconsult.jmoller.mapr.mapr.MaprPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.xtext.common.types.JvmFeature;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Feature Map</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link dk.nineconsult.jmoller.mapr.mapr.impl.FeatureMapImpl#getLeftField <em>Left Field</em>}</li>
 *   <li>{@link dk.nineconsult.jmoller.mapr.mapr.impl.FeatureMapImpl#getRightField <em>Right Field</em>}</li>
 *   <li>{@link dk.nineconsult.jmoller.mapr.mapr.impl.FeatureMapImpl#getExpr <em>Expr</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FeatureMapImpl extends MinimalEObjectImpl.Container implements FeatureMap
{
  /**
   * The cached value of the '{@link #getLeftField() <em>Left Field</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLeftField()
   * @generated
   * @ordered
   */
  protected JvmFeature leftField;

  /**
   * The cached value of the '{@link #getRightField() <em>Right Field</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRightField()
   * @generated
   * @ordered
   */
  protected JvmFeature rightField;

  /**
   * The cached value of the '{@link #getExpr() <em>Expr</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExpr()
   * @generated
   * @ordered
   */
  protected Expression expr;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FeatureMapImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MaprPackage.Literals.FEATURE_MAP;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JvmFeature getLeftField()
  {
    if (leftField != null && leftField.eIsProxy())
    {
      InternalEObject oldLeftField = (InternalEObject)leftField;
      leftField = (JvmFeature)eResolveProxy(oldLeftField);
      if (leftField != oldLeftField)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MaprPackage.FEATURE_MAP__LEFT_FIELD, oldLeftField, leftField));
      }
    }
    return leftField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JvmFeature basicGetLeftField()
  {
    return leftField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLeftField(JvmFeature newLeftField)
  {
    JvmFeature oldLeftField = leftField;
    leftField = newLeftField;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MaprPackage.FEATURE_MAP__LEFT_FIELD, oldLeftField, leftField));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JvmFeature getRightField()
  {
    if (rightField != null && rightField.eIsProxy())
    {
      InternalEObject oldRightField = (InternalEObject)rightField;
      rightField = (JvmFeature)eResolveProxy(oldRightField);
      if (rightField != oldRightField)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MaprPackage.FEATURE_MAP__RIGHT_FIELD, oldRightField, rightField));
      }
    }
    return rightField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JvmFeature basicGetRightField()
  {
    return rightField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRightField(JvmFeature newRightField)
  {
    JvmFeature oldRightField = rightField;
    rightField = newRightField;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MaprPackage.FEATURE_MAP__RIGHT_FIELD, oldRightField, rightField));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Expression getExpr()
  {
    return expr;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExpr(Expression newExpr, NotificationChain msgs)
  {
    Expression oldExpr = expr;
    expr = newExpr;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MaprPackage.FEATURE_MAP__EXPR, oldExpr, newExpr);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExpr(Expression newExpr)
  {
    if (newExpr != expr)
    {
      NotificationChain msgs = null;
      if (expr != null)
        msgs = ((InternalEObject)expr).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MaprPackage.FEATURE_MAP__EXPR, null, msgs);
      if (newExpr != null)
        msgs = ((InternalEObject)newExpr).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MaprPackage.FEATURE_MAP__EXPR, null, msgs);
      msgs = basicSetExpr(newExpr, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MaprPackage.FEATURE_MAP__EXPR, newExpr, newExpr));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MaprPackage.FEATURE_MAP__EXPR:
        return basicSetExpr(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MaprPackage.FEATURE_MAP__LEFT_FIELD:
        if (resolve) return getLeftField();
        return basicGetLeftField();
      case MaprPackage.FEATURE_MAP__RIGHT_FIELD:
        if (resolve) return getRightField();
        return basicGetRightField();
      case MaprPackage.FEATURE_MAP__EXPR:
        return getExpr();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MaprPackage.FEATURE_MAP__LEFT_FIELD:
        setLeftField((JvmFeature)newValue);
        return;
      case MaprPackage.FEATURE_MAP__RIGHT_FIELD:
        setRightField((JvmFeature)newValue);
        return;
      case MaprPackage.FEATURE_MAP__EXPR:
        setExpr((Expression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MaprPackage.FEATURE_MAP__LEFT_FIELD:
        setLeftField((JvmFeature)null);
        return;
      case MaprPackage.FEATURE_MAP__RIGHT_FIELD:
        setRightField((JvmFeature)null);
        return;
      case MaprPackage.FEATURE_MAP__EXPR:
        setExpr((Expression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MaprPackage.FEATURE_MAP__LEFT_FIELD:
        return leftField != null;
      case MaprPackage.FEATURE_MAP__RIGHT_FIELD:
        return rightField != null;
      case MaprPackage.FEATURE_MAP__EXPR:
        return expr != null;
    }
    return super.eIsSet(featureID);
  }

} //FeatureMapImpl
